package com.pro.springbootshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.FlashActivity;
import com.pro.springbootshop.entity.FlashEntry;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface FlashEntryMapper extends BaseMapper<FlashEntry> {
    @Select("select * from flash_entry where flash_activity_id=#{flashActivityId} limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "flash_entry_id",property = "flashEntryId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "buy_state",property = "buyState"),
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
            }
    )
    List<FlashEntry> getAllFlashEntry(@Param("pageNo") int pageNo, @Param("limit") int limit, @Param("flashActivityId") Integer flashActivityId);
    @Select("select * from flash_entry limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "flash_entry_id",property = "flashEntryId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "buy_state",property = "buyState"),
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
            }
    )
    List<FlashEntry> getAllFlashEntry_admin(@Param("pageNo") int pageNo, @Param("limit") int limit);
    @Select("select * from flash_entry where buyer_id=#{buyerId} and flash_activity_id=#{flashActivityId}")
    @Results(
            {
                    @Result(column = "flash_entry_id",property = "flashEntryId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "buy_state",property = "buyState"),
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
            }
    )
    List<FlashEntry> buyergetFlashEntry(@Param("buyerId") String buyerId, @Param("flashActivityId") Integer flashActivityId);
    @Select("select * from flash_entry where buyer_id=#{buyerId}limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "flash_entry_id",property = "flashEntryId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
                    @Result(column = "buy_state",property = "buyState"),
                    @Result(column = "flash_activity_id",property = "flashActivity",javaType = FlashActivity.class,
                            one=@One(select = "com.pro.springbootshop.mapper.FlashActivityMapper.selectById"))

            }
    )
    List<FlashEntry> buyerIdGetFlashEntry(@Param("pageNo") int pageNo, @Param("limit") int limit, @Param("buyerId") String buyerId);
}
